


inputFocus('.main-form');



//1.切换登录方式
changeView();
function changeView(){
	var $type_btn = $('.login-type .type-btn'),
		$view_model = $('.main-form .view-model');
		
	$type_btn.click(function(){
		//1.切换标记已选择
		$type_btn.removeClass('active');
		$(this).addClass('active');
		//2.切换视图
		$view_model.css('display','none');
		$view_model.eq($(this).index()).css('display','block');
		
		//3.清空已填数据
		$('.main-form .reset').trigger('click');
		clearInterval(timer);
		$send_btn.css('background-color','')
				.removeAttr('disabled')
				.text('发送验证码');
		timeOff = true;
		$('.main-form input').css('border-color','');
		
	});
}




//2.发送验证码的倒计时
var timer = null,
	time = null,
	timeOff = true;
var $send_btn = $('.input-code .send-codebtn');
$send_btn.click(function(){
	if(!timeOff){
		return;
	}
	time = 10;
	timeOff = false;
	$(this).css('background-color','#dddddd')
		.attr('disabled','true')
		.text(time+' s');
	timer = setInterval(function(){
		time--;
		if(time<0){
			clearInterval(timer);
			$send_btn.css('background-color','')
				.text('重新发送')
				.removeAttr('disabled');
			timeOff = true;	
			return;
		}
		$send_btn.text(time+' s');
	},1000)	
});








var oldHeight = $(window).height();
$(window).on('resize',function(){
	var _this = $(this);
	var nowHeight = $('body').height();
	$('body').animate({
		scrollTop:(oldHeight-nowHeight)*0.5
	},100);
});